import 'package:flutter/foundation.dart';
import 'package:image_picker/image_picker.dart';
import 'package:permission_handler/permission_handler.dart';

class SjMediaUtil {

  static final SjMediaUtil _instance = SjMediaUtil._internal();

  // 私有的构造函数
  SjMediaUtil._internal();

  // 公共的静态方法来获取该实例
  static SjMediaUtil get instance => _instance;
  
  Future<String?> pickImage() async {
    PermissionStatus status = await Permission.photos.request();
    if (status != PermissionStatus.granted) {
      return null;
    }

    XFile? imgfile = await ImagePicker().pickImage(source: ImageSource.gallery);
    if (imgfile == null) {
      return null;
    }
    String imgPath = imgfile.path;
    return imgPath;
  }
}
